﻿namespace Eff.Net
{
    /// <summary>
    /// udp客户端
    /// </summary>
    public class UpdSender
    {
        private readonly System.Net.Sockets.UdpClient _udpClient;
        /// <summary>
        /// 初始化数据
        /// </summary>
        /// <param name="ip">IP</param>
        /// <param name="port">Port</param>
        public UpdSender(string ip, int port)
        {
            _udpClient = new System.Net.Sockets.UdpClient(ip, port);
        }

        /// <summary>
        /// 发送信息包
        /// </summary>
        /// <param name="data"></param>
        public void SendMsg(byte[] data)
        {
            _udpClient.Send(data, data.Length);
        }
        /// <summary>
        /// 释放资源
        /// </summary>
        public void Disponse()
        {
            _udpClient.Close();
        }
    }
}
